
#include <gomoku/referee/DefaultReferee.h>

namespace gomoku
{
    DefaultReferee::DefaultReferee()
        : _gui(0), _black(0), _white(0), _match()
    {}

    DefaultReferee::~DefaultReferee()
    {

    }

    // signal
    void DefaultReferee::connectGui(IGui *gui)
    {
        _gui = gui;
    }

    void DefaultReferee::connectBlack(IPlayer *black)
    {
        _black = black;
    }

    void DefaultReferee::connectWhite(IPlayer *white)
    {
        _white = white;
    }

    // STATE title screen : from gui keep next match to launch.
    void DefaultReferee::nextMatch(Match const & match)
    {
        _match = match;
    }

    // STATE game : loop game while have not victory.
    void DefaultReferee::launch()
    {
    }

    // RULES
    bool DefaultReferee::checkMove(Move const & move)
    {
        return false;
    }

    // if move is correct update goban for referee, gui and players.
    void DefaultReferee::updateGoban(Move const & move)
    {
        _black->updateGoban(move);
        _white->updateGoban(move);
        _gui->updateGoban(move);
    }

    // switch player and said to gui
    void DefaultReferee::switchPlayer(Color color)
    {
        _gui->switchPlayer(color);
    }

}
